package com.example.demo.test005;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * s
 *
 * @author ws
 * @since 2023-11-23
 */
public class TimeUtils {
    public static void main(String[] args) {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 格式化当前时间为年月日字符串
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        String formattedDate = now.format(formatter);

        // 生成唯一字符串
        String uniqueString = UUID.randomUUID().toString().replaceAll("-", "");

        // 拼接年月日和唯一字符串
        String randomNumber = formattedDate + uniqueString;
        System.out.println(randomNumber);
    }
}
